<script>
    //扩展Array类型生成一个更加强大的Array类型
    class ArrayPro extends Array{
        getData(index){
            return this[index];
        }
        getSize(){
            return this.length;
        }
        getLast(){  //获得数组的最后一个元素的值
            return this.getData(this.getSize()-1);
        }
    }
    let myarray=new ArrayPro(1,2,3,4,5,6);
    console.log(myarray.getData(5));  //6
    console.log(myarray.getSize());  //6
    console.log(myarray.getLast());  //6

    Array.prototype.getLast=function(){
        return this[this.length-1];
    }
    Array.prototype.getData=function(index){
        return this[index];
    }
    Array.prototype.getSize=function(){
        return this.length;
    }

    let arr=[1,2,3,4,5,6];
    console.log(arr.getData(5));
    console.log(arr.getSize());
    console.log(arr.getLast());


</script>